import junit.framework.TestCase;
import org.junit.Test;
public class StringBufferDemoTest extends TestCase {
    StringBuffer a = new StringBuffer("StringBuffer");//测试12个字符
    StringBuffer b = new StringBuffer("StringBufferStringBuffer");//测试24个字符
    StringBuffer c = new StringBuffer("StringBufferStringBufferStringBuffer");//测试36个字符
    @Test
  public void testcharAt() throws Exception {
        assertEquals('S', a.charAt(0));
        assertEquals('n', a.charAt(4));
        assertEquals('r', a.charAt(11));
    }
    @Test
    public void testcapacity() throws Exception{
        assertEquals(28,a.capacity());
        assertEquals(40,b.capacity());
        assertEquals(52,c.capacity());
        }
     @Test
     public void testlength() throws Exception{
        assertEquals(12,a.length());
        assertEquals(24,b.length());
        assertEquals(36,c.length());
        }
    @Test
    public void testindexOf() throws Exception{
        assertEquals(0,a.indexOf("Str"));
        assertEquals(4,a.indexOf("ngB"));
        assertEquals(10,a.indexOf("er"));

    }
  }